package com.example.smartcity.ui.smartCity.Adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.smartcity.R
import com.example.smartcity.ui.smartCity.model.user

/**
 *
 *  ANDROID STUDIO -version 2022.19
 *  项目名: UserRecyclerView
 *  创建时间: 2023/2/15 23:59
 *  CodeAuthor: ikun
 *  email: 2506789532@qq.com
 **/
class UserRecyclerViewAdapter(val data: List<user>): RecyclerView.Adapter<UserRecyclerViewAdapter.ViewHolder>() {
    inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view){
        val uName = view.findViewById<TextView>(R.id.userTitle)
        val uContend = view.findViewById<TextView>(R.id.userContend)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val root = LayoutInflater.from(parent.context).inflate(R.layout.recyclerview_item_review, parent, false)
        return ViewHolder(root)
    }

    override fun getItemCount() = data.size

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val list = data[position]
        holder.uName.text = list.userName
        holder.uContend.text = list.userContend
    }
}